# Contributor: Jesse Mandel <jesse.mandel@gmail.com>
# Maintainer: Jesse Mandel <jesse.mandel@gmail.com>
pkgname=docker-credential-ecr-login
pkgver=0.9.0
pkgrel=0
pkgdesc="Credential helper for Docker to use the AWS Elastic Container Registry"
url="https://github.com/awslabs/amazon-ecr-credential-helper"
arch="x86_64 aarch64"
license="Apache-2.0"
makedepends="go"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://amazon-ecr-credential-helper-releases.s3.us-east-2.amazonaws.com/$pkgver/release.tar.gz"
builddir="$srcdir/ecr-login"
options="net"

export GOFLAGS="$GOFLAGS -trimpath -mod=readonly -modcacherw"
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -v -o bin/$pkgname \
		-ldflags "-X github.com/awslabs/amazon-ecr-credential-helper/ecr-login/version.Version=$pkgver"	\
		./cli/docker-credential-ecr-login
}

check() {
	go test -v -timeout 30s -short
}

package() {
	install -Dm755 bin/$pkgname \
		-t "$pkgdir"/usr/bin
	install -Dm644 "$builddir"/../docs/$pkgname.1 \
		"$pkgdir"/usr/share/man/man1/$pkgname.1
}

sha512sums="
9d8d53c8f3b206db0db5ea4c834a0cd30077cf692eee0a5a35ce8dc1d61cc7503db1f58f8798438c89cb33d1ccf8714686ecf3dc9b34a558ec4e930913cb1b0a  docker-credential-ecr-login-0.9.0.tar.gz
"
